#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2, urllib


url="http://ms.58control.cn/sms/warn"
def send_Msg(content,receiverList=['13522482231']):
    params={'function':1025,"priority":'G','ms':content}
    for m in receiverList:
        params['mo'] = m
        request=urllib2.Request(url=url,data=urllib.urlencode(params))
        response = urllib2.urlopen(request)
        response.read()

#get方式发送
getUrl="http://ms.58control.cn/sms/warn?%s"
def send_get(content,receiverList=['13522482231']):
    params={'function':1025,"priority":'G','ms':content}
    for m in receiverList:
        params['mo'] = m
#        p="function=1025&priority=G&ms=%smo=%s"
#        wholeUrl = getUrl % urllib.quote(p % (content,m))
        request=urllib2.Request(url=getUrl % urllib.urlencode(params))
        response = urllib2.urlopen(request)
        response.read()
        
if __name__ == '__main__':
    send_Msg('error!')

#cookies = urllib2.HTTPCookieProcessor()
#opener = urllib2.build_opener(cookies)
#while(1):
#    request = urllib2.Request(
#            url     = 'http://10.58.1.200/Vote_do.asp', #
#            headers = {'Content-Type' : 'application/xml','charset':'UTF-8','Referer':'http://10.58.1.200/Vote.asp?id=15'},
#            data    = urllib.urlencode(data))
#    f=opener.open(request)
#    print f.read()


# shell 命令发送http请求
# wget get/post
#wget 'http://www.linuxde.net/download?id=1'
#wget --post-data="user=user1&pass=pass1&submit=Login"  http://domain.com/path/page_need_login.php  

# curl get/post
#curl 'http://www.linuxde.net/download?id=1'
#curl -d/--data "user=user1&pass=pass1&submit=Login" http://domain.com/path/page_need_login.php  

